//---------------------------------------------------------------------------

#ifndef PrinterH
#define PrinterH
//---------------------------------------------------------------------------
#define PDF_V2
#ifdef PDF_V2
    #include ".\wpdf\WPPDFR2.hpp"
    #define WPDF_PAGE_PORTRAIT  0
    #define WPDF_PAGE_LANDSCAPE 90
#else
    #include ".\wpdf\WPPDFR2.hpp"
#endif


#include <printers.hpp>
enum TEICPrinterType {
    PT_Standard=1,
    PT_PDF,
    PT_Max = 2
};

#include "uDessin.h"


class TEICPrinter : public TObject
{
    private :
        TEICPrinterType     m_ePT;
        TPrinterOrientation m_Orientation;
    	  AnsiString          m_Title;
//        short               m_dmPrintQuality;
        TCoordonnee         m_Height;
        TCoordonnee         m_Width;
        int                 m_TypePapier, m_Zoom, m_AncResol;
        bool                m_bPageEnCours;
        unsigned int        m_PhysicalOffsetX;
        unsigned int        m_PhysicalOffsetY;
        TStringList        *m_LstDeviceCaps;
        TComponent         *vPDFPrinter;
        AnsiString          m_WatermarkEnCours;
        bool                m_ChangeOrientation, m_PaysagePortraitAssembles;
        HDC hMetaDC;
        TCanvas *CanvasMeta;


    	Graphics::TCanvas* __fastcall GetCanvas(void)const;
    	TPrinterOrientation __fastcall GetOrientation(void)const;
	    void __fastcall SetOrientation(TPrinterOrientation Value);
	    void __fastcall SetTitle(const AnsiString& Title);
	    void __fastcall SetCopies(const short Copies);
	    short __fastcall GetCopies(void);
	    short __fastcall GetPrintQuality()const;
	    bool __fastcall GetPrinting()const;
      double __fastcall GetCoefFontHeight()const;
      double __fastcall GetResolPourRTF()const;
	    void __fastcall SetWidth(const TCoordonnee Width);
	    void __fastcall SetHeight(const TCoordonnee Height);
	    void __fastcall SetTypePapier(int TypePapier);
	    void __fastcall SetZoom(int z);
	    void __fastcall SetPaysagePortraitAssembles( bool b);
      bool __fastcall GetPDF( ){return m_ePT == PT_PDF;};
      bool __fastcall GetMetaFile( ){return hMetaDC != NULL;};
      short __fastcall GetLogPixelsY();

    public :
        __fastcall TEICPrinter( TEICPrinterType ePT, const AnsiString &FileName = EmptyStr, bool bSilent = false);
        virtual __fastcall ~TEICPrinter( );

        static bool __fastcall SelectPrinter( const AnsiString &NomImprimante);

        void __fastcall Abort(void);
        void __fastcall BeginDoc( bool bDebutEffacable);
        void __fastcall EndDoc(void);
        void __fastcall NewPage( bool bDebutEffacable);
        void __fastcall ValideDebutPage(bool bOK = true);
        bool __fastcall CopieSupport( void);
        void __fastcall RectifieCoordonnees( TRect &Rect);
        void __fastcall RectifieCoordonnees( RECT &Rect);
        void __fastcall RectifieCoordonnees( TPoint &Pt);
        void __fastcall DrawEnhMetaFile(int x, int y, HENHMETAFILE meta);
        void __fastcall DrawTransparentBitmap( Graphics::TBitmap *Bmp,
                                               short xStart, short yStart, short w, short h,
                                               COLORREF cTransparentColor);
        void __fastcall DrawTGraphic( Graphics::TGraphic *Bmp, const TRect &r);

        __property Graphics::TCanvas* Canvas = {read=GetCanvas};
        __property TPrinterOrientation Orientation = {read=GetOrientation, write=SetOrientation, nodefault};
    	__property AnsiString Title = {read=m_Title, write=SetTitle};
        __property short dmPrintQuality =  {read=GetPrintQuality};
        __property short LogPixelsY =  {read=GetLogPixelsY};
        __property short Copies =  {read=GetCopies, write=SetCopies};
        __property bool Printing =  {read=GetPrinting};
        __property TCoordonnee Width =  {read=m_Width,write=SetWidth};
        __property TCoordonnee Height =  {read=m_Height,write=SetHeight};
        __property int         TypePapier = {read=m_TypePapier,write=SetTypePapier};
        __property int         Zoom       = {read=m_Zoom,write=SetZoom};
        __property unsigned int PhysicalOffsetX = {read=m_PhysicalOffsetX};
        __property unsigned int PhysicalOffsetY = {read=m_PhysicalOffsetY};
        __property bool         PDF = {read=GetPDF};
        __property double ResolPourRTF = {read=GetResolPourRTF};
        __property bool         PaysagePortraitAssembles = {read=m_PaysagePortraitAssembles,write=SetPaysagePortraitAssembles};
        __property bool         MetaFile = {read=GetMetaFile};



        int __fastcall GetDeviceCaps( int nIndex)const ;
};

#define IsPrinting()  ( (Glob->EICPrinter != NULL)/* && EICPrinter->Printing*/)
#endif
